package top.malaoshi.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Scheduler {

    @Bean
    public JobDetail sampleJobDetail() {

        return JobBuilder.newJob(Redis2MysqlJob.class).storeDurably().build();
    }

    @Bean
    public Trigger sampleJobTrigger(){
        // 每隔3秒执行一次
        SimpleScheduleBuilder scheduleBuilder =
                SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(6).repeatForever();
        return TriggerBuilder.newTrigger().forJob(sampleJobDetail()).withSchedule(scheduleBuilder).build();
    }

}
